<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/6
 * Time: 20:55
 */

date_default_timezone_set('PRC');
require_once "dataSQL.php";
require_once "rootDB.php";
file_put_contents("post.txt",json_encode($_POST)."\r\n",8);
$rootDB=new rootDB();
$content=isset($_POST['content'])?$_POST['content']:"";
$tel=isset($_POST['tel'])?$_POST['tel']:"";
$name=$_POST['name'];
$img=$_POST['img'];

$addtime=date("Y年m月d日 h点i分",time());
//$dataa=$rootDB->select_propALL($name);
//if($dataa==null) {
    $data = $rootDB->add_prop($name, $img,$content, $tel, $addtime);
    try {
        $result = $data;
        if ($result) {
            $dat = array(
                'message' => "提交成功",
            );
            echo json_encode($dat);
        } else {
            $dat = array(
                'message' => "提交失败",

            );
            echo json_encode($dat);

        }
    } catch (Exception $e) {

        // 回滚事务
        // $pdo->rollback();
        echo $e->getMessage();
    }
//}
//else{
//    $dat = array(
//        'message' => "你已经提交过信息了",
//
//    );
//    echo json_encode($dat);
//}


